<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('批量新增栏目')" />
	<link th:href="@{/css/cms/cms.css}" rel="stylesheet"/>
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal" id="form-channel-batch-add">
			<input type="hidden" name="token" th:value="${session.token}"/>
			<input id="treeId" name="parentId" type="hidden" th:value="${channel.id}" />
			<div class="form-group">
				<label class="col-sm-2 control-label ">上级栏目：</label>
				<div class="col-sm-9">
				    <div class="input-group">
						<input class="form-control" type="text" onclick="selectChannelTree()" id="treeName" readonly="readonly" th:value="${channel.channelName}">
					    <span class="input-group-addon"><i class="fa fa-search"></i></span>
				    </div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">批量栏目：</label>
				<div class="col-sm-5">
					<textarea name="channels" class="form-control tabIndent" rows="16"></textarea>
				</div>
				<div class="col-sm-4">
					<div class="alert alert-info" role="alert">
						请在输入框输入栏目名称，如需新增下级子栏目，则只需缩进一个Tab，以此类推新增子栏目的子栏目，栏目之间不允许存在空行。
						示例：
						<p>栏目一</p>
						<p>栏目二</p>
							<p style="text-indent:2em">子栏目一</p>
							<p style="text-indent:2em">子栏目二</p>
								<p style="text-indent:4em">子栏目一</p>
								<p style="text-indent:4em">子栏目二</p>
						<p>栏目三</p>
							<p style="text-indent:2em">子栏目一</p>
							<p style="text-indent:2em">子栏目二</p>
					</div>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript" charset="utf-8" th:src="@{/js/tabIndent.js}"></script>
	<script type="text/javascript">
		var prefix = ctx + "cms/channel";
		
		tabIndent.renderAll();
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/batch", $('#form-channel-batch-add').serialize());
	        }
	    }
	
		/*栏目管理-新增-选择父栏目树*/
		function selectChannelTree() {
			var options = {
				title: '栏目选择',
				width: "380",
				url: prefix + "/selectChannelTree/" + $("#treeId").val(),
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doSubmit(index, layero){
			var body = layer.getChildFrame('body', index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			layer.close(index);
		}
	</script>
</body>
</html>
